<template>
  <div class="app-container">
    <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="68px"
    >
      <el-form-item label="一级销区" prop="userXq1">
        <el-input
            v-model="queryParams.userXq1"
            placeholder="请输入一级销区"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="二级销区" prop="userXq2">
        <el-input
            v-model="queryParams.userXq2"
            placeholder="请输入二级销区"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="品牌" prop="userPp">
        <el-input
            v-model="queryParams.userPp"
            placeholder="请输入品牌"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item
      >
      <el-form-item label="工号" prop="userCode">
        <el-input
            v-model="queryParams.userCode"
            placeholder="请输入用户账号"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="userName">
        <el-input
            v-model="queryParams.userName"
            placeholder="请输入用户姓名"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="userState">
        <el-input
            v-model="queryParams.userState"
            placeholder="请输入用户状态"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户类型" prop="userType">
        <el-select
            v-model="queryParams.userType"
            placeholder="请选择用户类型"
            clearable
            size="small"
        >
          <el-option label="请选择字典生成" value=""/>
        </el-select>
      </el-form-item>
      <el-form-item label="酷家乐号" prop="kjlCode">
        <el-input
            v-model="queryParams.kjlCode"
            placeholder="请输入酷家乐号"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="店面" prop="userDept">
        <el-input
            v-model="queryParams.userDept"
            placeholder="请输入店面"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="会员到期">
        <el-date-picker
            v-model="dateRange"
            size="small"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
        >搜索
        </el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
        >重置
        </el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['user:sjyuser:add']"
        >开通账号
        </el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
        >导出
        </el-button
        >
      </el-col>
    </el-row>

    <el-table
        v-loading="loading"
        border
        stripe
        :data="sjyuserList"
        @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column
          label="用户账号"
          align="center"
          prop="userCode"
          width="120"
      />
      <el-table-column label="用户姓名" align="center" prop="userName" width="100"/>
      <el-table-column label="用户状态" align="center" prop="userState" width="100"/>
      <el-table-column label="用户类型" align="center" prop="userType" width="100"/>
      <el-table-column label="酷家乐会员名称" align="center" prop="kjlVipName" width="100"/>
      <el-table-column label="酷家乐会员开始时间" align="center" prop="kjlVipStartTime" width="100"
                       :formatter="formatStartDate"
      />
      <el-table-column label="酷家乐会员到期时间" align="center" prop="kjlVipEndTime" width="100" :formatter="formatEndDate"/>
      <el-table-column label="一级销区" align="center" prop="userXq1" width="100"/>
      <el-table-column label="一级销区code" align="center" prop="userXq1Code" width="120"/>
      <el-table-column label="二级销区" align="center" prop="userXq2" width="100"/>
      <el-table-column label="二级销区code" align="center" prop="userXq2Code" width="120"/>
      <el-table-column label="品牌" align="center" prop="userPp" width="100"/>
      <el-table-column label="品牌code" align="center" prop="userPpCode" width="100"/>
      <el-table-column
          label="店面"
          align="center"
          prop="userDept"
          width="155"
      />
      <el-table-column label="用户邮箱" align="center" prop="userEmail" width="200"/>
      <el-table-column
          label="酷家乐号"
          align="center"
          prop="kjlCode"
          width="300"
      />
      <el-table-column
          label="操作"
          fixed="right"
          align="center"
          class-name="small-padding fixed-width"
          width="150"
      >
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleInherit(scope.row)"
              v-hasPermi="['user:sjyuser:edit']"
          >继承</el-button>
          <el-button
              size="mini"
              type="text"
              @click="handleOpenResetPsw(scope.row)"
          >重置密码</el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              v-if="scope.row.userType==2"
              @click="handleOpenResetXq(scope.row)"
          >修改销区</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 继承用户对话框 -->
    <el-dialog
        title="继承"
        :visible.sync="isShowInheritDialog"
        width="500px"
        append-to-body
        center
        :show-close="false"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
    >
      <el-form ref="inheritForm" :model="inheritForm" label-width="80px">
        <el-form-item label="原用户">
          <el-input :value="inheritForm.oldUserName" :disabled="true"/>
        </el-form-item>
        <el-form-item label="继承人" prop="newUserName">
          <el-input
              v-model="inheritForm.newUserName"
              v-on:click.native="openDeptUserSelector()"
              readonly="readonly"
              placeholder="请选择继承人"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('inheritForm')"
          >继承
          </el-button
          >
          <el-button @click="cancel()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 添加或修改用户管理对话框 -->
    <el-dialog
        :title="title"
        :visible.sync="open"
        width="500px"
        append-to-body
        :show-close="false"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
    >
      <el-tabs v-model="activeName">
        <el-tab-pane label="华耐员工" name="first">
          <el-form ref="honorForm" :model="honorForm" label-width="80px">
            <el-form-item label="开通人员" prop="userName">
              <el-input
                  v-model="honorForm.userName"
                  v-on:click.native="openDeptUserSelector()"
                  readonly="readonly"
                  placeholder="请选择开通人员"
              />
            </el-form-item>
            <el-form-item
                label="工号"
                v-on:click.native="openDeptUserSelector()"
                readonly="readonly"
                prop="userCode"
            >
              <el-input
                  v-model="honorForm.userCode"
                  placeholder="请选择开通人员"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm('honorForm')"
              >立即创建
              </el-button
              >
              <el-button @click="cancel()">取消</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="外部" name="second">
          <el-form ref="form" :model="form" label-width="80px" :rules="rules">
            <el-form-item label="姓名" prop="userName">
              <el-input v-model="form.userName" placeholder="请输入姓名"/>
            </el-form-item>
            <el-form-item label="用户账号" prop="userCode">
              <el-input
                  v-model="form.userCode"
                  maxlength="11"
                  placeholder="请输入用户账号"
              />
            </el-form-item>
            <el-form-item label="密码" prop="userPassword">
              <el-input
                  v-model="form.userPassword"
                  type="password"
                  show-password
                  placeholder="请输入密码"
              />
            </el-form-item>
            <el-form-item label="一级销区" prop="userXq1Code">
              <el-select
                  v-model="form.userXq1Code"
                  placeholder="请选择"
                  @change="onChangeXq1"
              >
                <el-option
                    v-for="dict in xq1Options"
                    :key="dict.RP02"
                    :label="dict.RP02NAME"
                    :value="dict.RP02"
                  ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="二级销区" prop="userXq2Code">
              <el-select
                  v-model="form.userXq2Code"
                  placeholder="请选择"
                  @change="onChangeXq2"
              >
                <el-option
                    v-for="dict in xq2Options"
                    :key="dict.RP03"
                    :label="dict.RP03NAME"
                    :value="dict.RP03"
                  ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="品牌" prop="userPpCode">
              <el-select
                  v-model="form.userPpCode"
                  placeholder="请选择"
                  @change="onChangeBrand"
              >
                <el-option
                    v-for="dict in brandOptions"
                    :key="dict.BRAND_CODE"
                    :label="dict.BRAND_NAME"
                    :value="dict.BRAND_CODE"
                  ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm('form')"
              >立即创建
              </el-button
              >
              <el-button @click="cancel()">取消</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <!-- 选择人员信息 -->
    <el-dialog
        class="admin-selector"
        title="请选择1位员工"
        :visible.sync="deptUserSelectorOpen"
        :before-close="closeDeptUserSelector"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        width="800"
    >
      <qywx-dept-user-selector
          ref="userSelector"
          :selectedList="selectedList"
          @onSelectUser="setSelectedList"
          @onDelUser="delSelectedList"
          :isSelectDept="false"
          :showTag="false"
          @onSelectDept="setSelectedList"
      ></qywx-dept-user-selector>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="settingDeptUser">确 定</el-button>
        <el-button @click="closeDeptUserSelector">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
        title="重置密码"
        :visible.sync="isOpenResetPsw"
        width="800"
    >
      <el-form inline>
        <el-form-item label="新密码">
          <el-input
              v-model="newPsw"
              placeholder="请输入新密码"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleResetPsw">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog
        title="修改销区"
        :visible.sync="isOpenResetXq"
        width="800"
    >
      <el-form :model="form" label-width="80px" :rules="rules">
        <el-form-item label="姓名" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入姓名" disabled/>
        </el-form-item>
        <el-form-item label="用户账号" prop="userCode">
          <el-input
              v-model="form.userCode"
              maxlength="11"
              placeholder="请输入用户账号"
              disabled
          />
        </el-form-item>
        <el-form-item label="一级销区" prop="userXq1Code">
          <el-select
              v-model="form.userXq1Code"
              placeholder="请选择"
              @change="onChangeXq1"
          >
            <el-option
                v-for="dict in xq1Options"
                :key="dict.RP02"
                :label="dict.RP02NAME"
                :value="dict.RP02"
              ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="二级销区" prop="userXq2Code">
          <el-select
              v-model="form.userXq2Code"
              placeholder="请选择"
              @change="onChangeXq2"
          >
            <el-option
                v-for="dict in xq2Options"
                :key="dict.RP03"
                :label="dict.RP03NAME"
                :value="dict.RP03"
              ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="品牌" prop="userPpCode">
          <el-select
              v-model="form.userPpCode"
              placeholder="请选择"
              @change="onChangeBrand"
          >
            <el-option
                v-for="dict in brandOptions"
                :key="dict.BRAND_CODE"
                :label="dict.BRAND_NAME"
                :value="dict.BRAND_CODE"
              ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleResetQx">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import requestCrm from '@/utils/requestCrm'
import {
  listSjyuser,
  getSjyuser,
  deleteKjlUser,
  addSjyuser,
  inheritSjyuser,
  updateSjyuser,
  exportSjyuser,
  resetPsw
} from '@/api/user/sjyuser'
import QywxDeptUserSelector from '@/components/QywxDeptUserSelector'

export default {
  name: 'Sjyuser',
  components: { QywxDeptUserSelector },
  data() {
    const validatePhone = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入手机号'))
      } else {
        if (!/^1[3456789]\d{9}$/.test(value)) {
          callback(new Error('请输入正确的手机号'))
        } else {
          callback()
        }
      }
    }
    return {
      isShowInheritDialog: false,
      inheritForm: {},
      selectedList: [],
      deptUserSelectorOpen: false,
      activeName: 'first',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 日期范围
      dateRange: [],
      // 总条数
      total: 0,
      // 用户管理表格数据
      sjyuserList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        userCode: undefined,
        userState: undefined,
        userType: undefined,
        kjlCode: undefined,
        userXq1: undefined,
        userXq1Code: undefined,
        userXq2: undefined,
        userXq2Code: undefined,
        userPp: undefined,
        userPpCode: undefined,
        userDept: undefined,
        beginTime: '',
        endTime: ''
      },
      form: {},
      honorForm: {},
      rules: {
        userName: [{ required: true, message: '请输名称', trigger: 'blur' }],
        userCode: [
          /* {
            required: true,
            message: '请输入手机号',
            validator: validatePhone,
            trigger: 'blur'
          } */
          { required: true, message: '请输用户账号', trigger: 'blur' }
        ],
        userPassword: [
          { required: true, message: '请填写密码', trigger: 'blur' }
        ],

        userXq1Code: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        userXq2Code: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        userPpCode: [
          { required: true, message: '请选择', trigger: 'blur' }
        ]
      },
      resetPswId:'',
      isOpenResetPsw:false,
      newPsw:'',
      xq1Options:[],
      xq2Options:[],
      brandOptions:[],
      isOpenResetXq:false
    }
  },
  created() {
    this.getList()
    this.getXQ1Options()
  },
  methods: {
    onChangeXq1(e){
      let xq1 = this.xq1Options.find(obj=>{
        return e == obj.RP02
      })
      if(xq1){
        this.form.userXq1 = xq1.RP02NAME
        this.form.userXq2 = undefined
        this.form.userXq2Code = undefined
        this.form.userPp = undefined
        this.form.userPpCode = undefined
        this.xq2Options = []
        this.brandOptions = []
      }
      this.getXQ2Options(xq1.RP02)
    },
    onChangeXq2(e){
      let xq2 = this.xq2Options.find(obj=>{
        return e == obj.RP03
      })
      if(xq2){
        this.form.userXq2 = xq2.RP03NAME
        this.form.userPp = undefined
        this.form.userPpCode = undefined
        this.brandOptions = []
      }
      this.getBrandOptions(xq2.RP03)
    },
    onChangeBrand(e){
      let brand = this.brandOptions.find(obj=>{
        return e == obj.BRAND_CODE
      })
      if(brand){
        this.form.userPp = brand.BRAND_NAME
      }
    },
    getXQ1Options(){
      requestCrm({
        url:'WxService?method=getXQ1ByMemCode',
        method: 'post',
        data: {memCode:'HN029163'}
      }).then(res=>{
        this.xq1Options = res.data
      })
    },
    getXQ2Options(xq1code){
      requestCrm({
        url:'WxService?method=getXQ2ByMemCodeAndXQ1',
        method: 'post',
        data: {xq1code, memCode:'HN029163'}
      }).then(res=>{
        this.xq2Options = res.data
      })
    },
    getBrandOptions(xq2Code){
      requestCrm({
        url:'WxService?method=getBrandByMemCodeAndXQ2',
        method: 'post',
        data: {xq2Code, memCode:'HN029163'}
      }).then(res=>{
        this.brandOptions = res.data
      })
    },
    formatStartDate(row) {
      if (row.kjlVipStartTime) {
        return row.kjlVipStartTime.split(' ')[0] || ''
      }
    },
    formatEndDate(row) {
      if (row.kjlVipEndTime) {
        return row.kjlVipEndTime.split(' ')[0] || ''
      }
    },
    /** 查询用户管理列表 */
    getList() {
      this.loading = true
      listSjyuser(this.queryParams).then((response) => {
        this.sjyuserList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      if (this.open) {
        this.open = false
      }
      if (this.isShowInheritDialog) {
        this.isShowInheritDialog = false
      }
      this.reset()
    },
    // 表单重置
    reset() {
      this.resetForm('honorForm')
      this.form = {
        userName:undefined,
        userCode:undefined,
        userPassword:undefined,
        userXq1:undefined,
        userXq1Code:undefined,
        userXq2:undefined,
        userXq2Code:undefined,
        userPp:undefined,
        userPpCode:undefined
      }
      this.resetForm('inheritForm')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      if (this.dateRange && this.dateRange.length > 0) {
        this.queryParams.beginTime = this.dateRange[0] || ''
        this.queryParams.endTime = this.dateRange[1] || ''
      }
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    handleOpenResetXq(row){
      this.reset()
      this.form.id = row.id
      this.form.userXq1 = row.userXq1
      this.form.userXq1Code = row.userXq1Code
      this.form.userXq2 = row.userXq2
      this.form.userXq2Code = row.userXq2Code
      this.form.userPp = row.userPp
      this.form.userPpCode = row.userPpCode
      this.form.userName = row.userName
      this.form.userCode = row.userCode
      if(this.form.userXq1){
        this.getXQ2Options(this.form.userXq1Code)
      }
      if(this.form.userXq2){
        this.getBrandOptions(this.form.userXq2Code)
      }
      this.isOpenResetXq = true
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加用户管理'
    },
    /** 修改按钮操作 */
    handleInherit(row) {
      this.reset()
      this.inheritForm.oldUserName = row.userName
      this.inheritForm.oldUserCode = row.userCode
      this.isShowInheritDialog = true
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (formName === 'honorForm') {
            if (!this.honorForm.userCode) {
              this.msgError('请至少选择一个开通人员')
              return false
            }
            this.honorForm.userType = '1'
            addSjyuser(this.honorForm).then((response) => {
              if (response.code === 200) {
                this.msgSuccess('新增成功')
                this.open = false
                this.getList()
              }
            })
          } else if (formName === 'form') {
            this.form.userType = '2'
            addSjyuser(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess('新增成功')
                this.open = false
                this.getList()
                this.reset()
              }
            })
          } else if (formName === 'inheritForm') {
            inheritSjyuser(this.inheritForm).then((response) => {
              if (response.code === 200) {
                this.msgSuccess('继承用户成功')
                this.isShowInheritDialog = false
                this.getList()
                this.reset()
              }
            })
          }
        } else {
          this.msgError('请填写表单选项')
          return false
        }
      })
    },
     /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm('是否确认删除该数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return deleteKjlUser(row.id);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$confirm('是否确认导出所有用户管理数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(function() {
            return exportSjyuser(queryParams)
          })
          .then((response) => {
            this.download(response.msg)
          })
          .catch(function() {
          })
    },
    openDeptUserSelector() {
      const that = this
      this.selectedList = []
      this.deptUserSelectorOpen = true
      setTimeout(function() {
        that.$refs.userSelector.getDeptTree()
      }, 40)
    },
    closeDeptUserSelector() {
      this.deptUserSelectorOpen = false
    },
    settingDeptUser() {
      const that = this
      if (that.selectedList.length > 0) {
        if (that.isShowInheritDialog) {
          that.open = false
          that.inheritForm.newUserCode = that.selectedList[0].userId
          that.inheritForm.newUserName = that.selectedList[0].userName
          that.honorForm.userCode = ''
          that.honorForm.userName = ''
        } else if (that.open) {
          that.isShowInheritDialog = false
          that.honorForm.userCode = that.selectedList[0].userId
          that.honorForm.userName = that.selectedList[0].userName
          that.inheritForm.newUserCode = ''
        }
        that.deptUserSelectorOpen = false
      }
    },
    setSelectedList(item, val) {
      let findIndex = this.selectedList.findIndex(function(obj) {
        return (
            (obj.userId && obj.userId == item.userId) ||
            (!obj.userId && obj.id == item.id && obj.label == item.label)
        )
      })
      if (val) {
        if (findIndex == -1) {
          this.selectedList.push(item)
        }
      } else {
        this.selectedList.splice(findIndex, 1)
      }
    },
    delSelectedList(item) {
      let findIndex = this.selectedList.findIndex(function(obj) {
        return (
            (obj.userId && obj.userId == item.userId) ||
            (!obj.userId && obj.id == item.id && obj.label == item.label)
        )
      })
      if (findIndex > -1) {
        this.selectedList.splice(findIndex, 1)
      }
    },
    handleOpenResetPsw(row){
      this.resetPswId = row.id
      this.newPsw = ''
      this.isOpenResetPsw = true
    },
    handleResetPsw(){
      this.$confirm('是否确认重置该账号密码?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(()=>{
        resetPsw({id:this.resetPswId, userUpdatePassword:this.newPsw}).then((response) => {
          this.isOpenResetPsw = false
          this.msgSuccess('操作成功')
          this.resetQuery()
        })
      }).catch(()=>{

      })
    },
    handleResetQx(){
      this.loading = true
      let params = {
        id : this.form.id,
        userXq1 : this.form.userXq1,
        userXq1Code : this.form.userXq1Code,
        userXq2 : this.form.userXq2,
        userXq2Code : this.form.userXq2Code,
        userPp : this.form.userPp,
        userPpCode : this.form.userPpCode,
      }
      updateSjyuser(params).then((response) => {
        if (response.code === 200) {
          this.msgSuccess('修改成功')
          this.isOpenResetXq = false
          this.getList()
          this.reset()
        }
      })
    }
    
  }
}
</script>
